package hibernate;
// Generated Aug 6, 2012 8:52:27 AM by Hibernate Tools 3.2.1.GA

import java.util.Date;
import java.util.List;

/**
 * This is a comparable class. There should be no overlap of times for schedules
 * for a student.
 *
 */
public class Schedule implements java.io.Serializable, Comparable {

    private int schedId;
    private int userId;        //UserId of the student
    private Date schedstart;   //Use this to determine whether this is the current schedule
    private Date schedstop;
    private Date schedCreatedOn;
    private Date schedUdatedOn;
    private String startDate;
    private List<ScheduledActivity> activities;

    public Schedule() {
    }

    public Schedule(int schedId) {
        this.schedId = schedId;
    }
    public String getStartDate(){
        return startDate;
    }
    
    public void setStartDate(String date){
        startDate = date;
    }

    public Schedule(int schedId, Date schedstart, Date schedstop) {
        this.schedId = schedId;
        this.schedstart = schedstart;
        this.schedstop = schedstop;
    }

    public int getSchedId() {
        return this.schedId;
    }

    public void setSchedId(int schedId) {
        this.schedId = schedId;
    }

    public int getUserId() {
        return userId;
    }

    public Date getSchedCreatedOn() {
        return schedCreatedOn;
    }

    public void setSchedCreatedOn(Date schedCreatedOn) {
        this.schedCreatedOn = schedCreatedOn;
    }

    public Date getSchedUdatedOn() {
        return schedUdatedOn;
    }

    public void setSchedUdatedOn(Date schedUdatedOn) {
        this.schedUdatedOn = schedUdatedOn;
    }

    public List<ScheduledActivity> getActivities() {
        return activities;
    }

    public void setActivities(List<ScheduledActivity> activities) {
        this.activities = activities;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public Date getSchedstart() {
        return this.schedstart;
    }

    public void setSchedstart(Date schedstart) {
        this.schedstart = schedstart;
    }

    public Date getSchedstop() {
        return this.schedstop;
    }

    public void setSchedstop(Date schedstop) {
        this.schedstop = schedstop;
    }

    @Override
    public int compareTo(Object o) {

        Schedule s = (Schedule) o;
        if (this.userId != s.userId) {
            return -1;
        }
        if ((s.schedstart.before(this.schedstop))
                && ((s.schedstart.equals(this.schedstart)
                || (s.schedstart.after(this.schedstart))))) {
            return 0;
        }
        return -1;
    }
}
